<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Mail
 *
 * @author Administrator
 */
class Mail {

    public static function sendMail($email,$subject,$content,$attachment=null) {
        vendor("PHPMailer.class#phpmailer");
        $mail = new PHPMailer(true);

        $mail->IsSMTP(); // telling the class to use SMTP

        try {
            $mail->Host = "smtp.qq.com"; // SMTP server 部分邮箱不支持SMTP，QQ邮箱里要设置开启的
            $mail->SMTPDebug = false;        // 改为2可以开启调试
            $mail->SMTPAuth = true;                  // enable SMTP authentication
            $mail->Host = "smtp.qq.com"; // sets the SMTP server
            $mail->Port = 25;                 // set the SMTP port for the GMAIL server
            $mail->CharSet = "UTF-8";            // 这里指定字符集！解决中文乱码问题
            $mail->Encoding = "base64";
            $mail->Username = "401305079"; // SMTP account username
            $mail->Password = "lc191026";        // SMTP account password
            $mail->AddAddress($email, '');
            $mail->SetFrom('401305079@qq.com', '广基瑞特地产');     //发送者邮箱            
            $mail->Subject = $subject;            
            $mail->MsgHTML($content);
            if( $attachment != null && file_exists($attachment) ) {
            	$mail->AddAttachment($attachment);      // attachment
            }
            // $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
            $mail->Send();            
        } catch (phpmailerException $e) {
            echo $e->errorMessage(); //Pretty error messages from PHPMailer
        } catch (Exception $e) {
            echo $e->getMessage(); //Boring error messages from anything else!
        }
    }

}

?>
